/*
 * PlanetRed.cpp
 *
 *  Created on: 17/05/2013
 *      Author: vitor
 */

#include "PlanetRed.h"

PlanetRed::PlanetRed(Sprite* sprite, int hitPoints, float x, float y,
		GameObject* target, Sprite* bulletSprite) :
		Planet(sprite, hitPoints, x, y) {
	this->target = target;
	this->bulletSprite = bulletSprite;
	shotCooldown.start(SHOT_COOLDOWN);
}

int PlanetRed::update(double dt) {

	shotCooldown.update();

	if (shotCooldown.isDone() && target) {
		BulletManager::instantiate(*this->box.getPositionRef(),
				Vector2(
						target->getBox()->getPositionRef()->getX()
								- this->box.getPositionRef()->getX(),
						target->getBox()->getPositionRef()->getY()
								- this->box.getPositionRef()->getY()).normalize().constantProduct(
						150), true, bulletSprite);
		shotCooldown.start(SHOT_COOLDOWN);
	}

	return 0;
}

